package com.clss.commandhelper.function.casedetail;

import android.content.Context;

import com.clss.commandhelper.base.BaseJson;
import com.clss.commandhelper.base.BaseModel;
import com.clss.commandhelper.net.ApiClient;
import com.clss.commandhelper.tools.SpHelper;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Callback;

/**
 *
 * @author liuv
 * @date 2017/11/22
 */

public class CaseDetailModel extends BaseModel {
    private static final String TAG = "CaseDetailModel";

    public CaseDetailModel(Context context) {
        super(context);
    }

    public void getCaseDetail(String id, Callback<BaseJson> callback){
        mCall = ApiClient.apiList.getCaseDetail(SpHelper.getInstance().getToken(), id);
        mCall.enqueue(callback);
    }

    public void changeCaseStatus(String id, String taskId, int status, String code, Callback<BaseJson> callback){
        Map<String, String> body = new HashMap<>(4);
        body.put("id", id);
        body.put("policeInfoTaskId", taskId);
        body.put("status", status + "");
        body.put("areaCode", code);
        mCall = ApiClient.apiList.changeCaseStatus(SpHelper.getInstance().getToken(), body);
        mCall.enqueue(callback);
    }

    public void joinVideoRoom(String taskId, String dispatchId, double longitude, double latitude, String address,
                              Callback<BaseJson> callback){
        Map<String, String> body = new HashMap<>(6);
        body.put("taskId", taskId);
        body.put("dispatchId", dispatchId);
        body.put("isNew", "0");
        body.put("longitude", longitude + "");
        body.put("latitude", latitude + "");
        body.put("address", address);

        mCall = ApiClient.apiList.joinVideoRoom(SpHelper.getInstance().getToken(), body);
        mCall.enqueue(callback);
    }

    public void refreshLocation(String policeInfoAddress, String lat, String lng, String taskId, Callback<BaseJson> callback){
        Map<String, String> body = new HashMap<>(6);
        body.put("taskId", taskId);
        body.put("lat", lat);
        body.put("lng", lng);
        body.put("policeInfoAddress", policeInfoAddress);

        mCall = ApiClient.apiList.updateTaskLocation(SpHelper.getInstance().getToken(), body);
        mCall.enqueue(callback);
    }
}
